// pages/teameditop/teameditop.js
const app = getApp()
var util = require("../../utils/utils.js");
Page({
  data: {

  },
  formSubmit(e) {
    let params = {
      id: this.data.marInfo.id,
      marineName: e.detail.value.marineName,
      marineSlogan: e.detail.value.marineSlogan,
      score: e.detail.value.score,
      marinePrize: e.detail.value.marinePrize,
      comment: e.detail.value.comment
    }
    if (!params.marineName) {
      wx.showToast({ title: '队伍名称不能为空', icon: 'none', duration: 1000 });
      return;
    }
    if (!params.marineSlogan) {
      wx.showToast({ title: '队伍口号不能为空', icon: 'none', duration: 1000 });
      return;
    }
    wx.request({
      url: app.httpUrl + '/activity/tutor/updateActMarInfo',
      header: {
        'xcx-xtoken': app.globalData.openid,
        'content-type': 'application/json' // 默认值
      },
      data: params,
      method: "POST",
      success: (res) => {
        var signData = res.data.data;
        if (res.data.code == '000') {
          wx.showToast({ title: '修改成功', duration: 2000 });
          return;
        }
        wx.showToast({ title: '修改，请刷新再试', icon: 'none', duration: 2000 });
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let that = this;
    wx.request({
      url: app.httpUrl + '//activity/queryActMarInfo/' + options.marineId,
      header: {
        'xcx-xtoken': app.globalData.openid,
        'content-type': 'application/json' // 默认值
      },
      method: "GET",
      success: (res) => {
        that.setData({
          marInfo: res.data.data
        })
      }
    })
  },
  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})